﻿using System;
using System.Collections.Generic;
using System.Text;
using EasyStudy.Properties;
using System.Data;

namespace EasyStudy.Logic.DataStatistics
{
    public class DataStatisticsDBMgr
    {
        public static int[] GetMonthTaskNumbers(int year, int month)
        {
            int[] mNumbers = new int[DateTime.DaysInMonth(year, month)];
            Settings setting = new Settings();
            DateTime dt = new DateTime(year, month, 1);

            String sql = string.Format(setting.SqlGetTasksByCreateTime, dt.ToString("yy-MM"));
            DataTable datas = EbbTaskDBMgr.dbHelper.ExecuteDataTable(sql, null);

            foreach (DataRow dr in datas.Rows)
            {
                string createTime = dr["CREATE_TIME"].ToString();
                string daystr = createTime.Split(" ".ToCharArray())[0].Split("-".ToCharArray())[2];
                int day = int.Parse(daystr);
                mNumbers[day - 1] += 1; 
            }

            return mNumbers;
        }
    }
}
